import { createRouter, createWebHistory } from 'vue-router'
import VueLayout from '../layout/Layout.vue'

const constantRoutes = [
    {
        path: '/',
        name: 'VueLayout',
        component: VueLayout,
        redirect: "/Login",
        children: [
            {
                path: '/home',
                name: 'VueHome',
                component: () => import("@/layout/Home")
            },
            {
                path: '/EmailSystemPages/SendEmail/Send',
                name: 'Vuesend',
                component: () => import("@/views/EmailSystemPages/SendEmail/Send")
            },
            {
                path: '/EmailSystemPages/SendEmail/Success',
                name: 'Vuesuccess',
                component: () => import("@/views/EmailSystemPages/SendEmail/Success")
            },
            {
                path: '/EmailSystemPages/ReceiveEmail/Receive',
                name: 'Vuereceive',
                component: () => import("@/views/EmailSystemPages/ReceiveEmail/Receive")
            },
            {
                path: '/EmailSystemPages/AddressBook/AddressBook',
                name: 'Vueaddressbook',
                component: () => import("@/views/EmailSystemPages/AddressBook/AddressBook")
            },
            {
                path: '/EmailSystemPages/AddressBook/Addcont',
                name: 'Vueaddcont',
                component: () => import("@/views/EmailSystemPages/AddressBook/Addcont")
            },
            {
                path: '/EmailSystemPages/email/email',
                name: 'Vueemail',
                component: () => import("@/views/EmailSystemPages/email/email")
            },
            {
                path: '/index',
                name: 'VueIndex',
                component: () => import("@/views/Index")
            },
            {
                path: '/EmailSystemPages/draft/draft',
                name: 'Vuedraft',
                component: () => import("@/views/EmailSystemPages/draft/draft")
            },
            // 新添加的 AI 助手页面
            {
                path: '/ai-assistant',
                name: 'AIAssistant',
                component: () => import("@/views/AIAssistant")
            }
        ]
    },
    {
        path: '/Login',
        name: 'VueLogin',
        component: () => import("@/views/Login")
    },
    {
        path: '/Login2',
        name: 'vueLogin2',
        component: () => import("@/views/Login2")
    }
]

const router = createRouter({
    mode: 'hash',
    history: createWebHistory(process.env.BASE_URL),
    routes: constantRoutes
})

export function resetRouter() {
    const newRouter = createRouter({
        mode: 'hash',
        history: createWebHistory(process.env.BASE_URL),
        routes: constantRoutes
    })
    router.matcher = newRouter.matcher
}

export default router
